<template>
    <div class="Ranking bgwhite mb15">
        <div class="HomeTit HomeTit_border">
            <div class="tit">排行</div>
        </div>
        <div class="RankingBox">
            <ul>
                <li v-for="(item, index) in hotPostList" :key="index" class="dot">
                <router-link :to="'/commentpost?id=' + item.id" tag="a"><i>{{ index+1 }}</i>{{item.title}}</router-link>
                </li>
            </ul>
        </div>
    </div>
</template>


<script setup name="Header">
import { postApi } from '@/api';
import { computed, ref, reactive, onBeforeMount } from 'vue';
import { useRouter } from 'vue-router';
const emit = defineEmits(['updateUserInfo']);

// 路由
const router = useRouter();

// 生命周期
onBeforeMount(() => {
    getPostList();                                         
})

/**
 * @name 排行帖子
 */
const hotPostList = ref([]);
const queryParams = reactive({
    isRecommend: false,
    keyword: '',
    sortField: 'readCount',
    sortOrder: 'desc',
    pageNo: 1,
    pageSize: 10,
})
const getPostList = () => {
    postApi.getPostList(queryParams).then((res) => {
        hotPostList.value = res.result.list;
    }).catch((err) => {})
}

</script>


<style lang="less" scoped></style>